/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.swta;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

/**
 *
 * @author Jan Korreck
 */
public class PackageContentPanel extends Panel {

    ListView l;
    MyItemPackage itemPackage;

    public PackageContentPanel(String id, IModel<?> model, MyItemPackage itemPackage) {
        super(id, model);

        this.itemPackage = itemPackage;

        this.l = new ListView("packageContent", itemPackage.getItemList()) {

            protected void populateItem(ListItem item) {
                MyItem actItem = (MyItem) item.getModelObject();

                item.add(new Label("id", actItem.getId()));
                item.add(new Label("category", actItem.getCategory()));
                item.add(new Label("name", actItem.getName()));
                item.add(new Label("weight", "" + actItem.getWeight()));
                item.add(new Label("unit", "" + actItem.getUnit()));
                item.add(new Label("count", "" + PackageContentPanel.this.itemPackage.getItems().get(actItem.getId()).intValue()));
                item.add(new Label("price", "" + actItem.getPrice()));
            }
        };

        this.add(this.l);
    }


}
